package ev.traffic;
import ev.agent.*;
import java.util.List;
import java.util.ArrayList;
public class Side{
	private int node;
	private int preNode;
	private int weight;
	private float ratio;
	private int carNum;
	private List<Car> carList;
	
	public Side(int preNode,int node,int weight) {
		this.preNode=preNode;
		this.node=node;
		this.weight=weight;
		carList = new ArrayList<Car>();
	}

	public int getPreNode(){
		return this.preNode;
	}

	public void setPreNode(int preNode){
		this.preNode=preNode;
	}

	public int getCarNum(){
		return this.carNum;
	}

	public void addCarNum(Car car){
			if(!carList.contains(car)){
					carList.add(car);
					this.carNum += 1;
			}
	}
	public void leave(Car car){
			if(carList.contains(car)){
					carList.remove(car);
					this.carNum -= 1;
			}
	}
	public int getNode(){
		return this.node;
	}

	public void setNode(int node){
		this.node=node;
	}

	public void setWeight(int weight){
	 	this.weight=weight;
	}

	public int getWeight(){
		return this.weight;
	}
	public void setRatio(float ratio){
		this.ratio = ratio;
	}
	public float getRatio(){
		float tempRatio = (float)carNum/100.0f;
		if(tempRatio >= 0.5f)
				tempRatio = 0.5f;
		this.setRatio(tempRatio);
		//if(((hh >= 7)&&(hh <= 9))||((hh >= 17)&&(hh <= 19)))
		//		this.setRatio(0.5f);
		//else
		//		this.setRatio(0);
		return this.ratio;
	}
}
